package com.wenjie.original.entity;

import com.mybatisflex.annotation.EnumValue;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.wenjie.common.enumHandler.IEnum;
import com.wenjie.original.entity.common.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.Arrays;


@Data
@Table("code_list")
@ApiModel("编号表")
public class CodeList extends BaseEntity {


    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @ApiModelProperty("参数主键")
    private Long codeListId;

    @ApiModelProperty("编号")
    private String code;

    @ApiModelProperty("创建日期yymmdd")
    private String date;

    @ApiModelProperty("当天生成的次数")
    private Integer flg;

    @ApiModelProperty("状态(1:未使用,2:完成)")
    private CODE_LIST_STATUS codeListStatus;


    @Getter
    @AllArgsConstructor
    public enum CODE_LIST_STATUS implements IEnum<Integer> {
        arg1(1, "未使用"), arg2(2, "完成");

        @EnumValue
        private Integer code;
        private String message;

        /**
         * @Description 通过code进行查询枚举值
         * @author wenjie
         * @date 2024/5/30 15:21
         */
        public static CODE_LIST_STATUS getBycode(Integer code) {
            return Arrays.stream(CODE_LIST_STATUS.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
        }
    }


}